﻿<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net"
         xmlns:db="http://www.springframework.net/database">

  <!-- Referenced by main application context configuration file -->
  <description>
    The Northwind object definitions for the Data Access Objects.
  </description>

  <!-- Property placeholder configurer for database settings -->
  <object type="Spring.Objects.Factory.Config.PropertyPlaceholderConfigurer, Spring.Core">
    <property name="ConfigSections" value="databaseSettings"/>
  </object>

  <!-- Database Configuration -->
  <db:provider id="DbProvider"
                   provider="SQLite-1.0.65"
                   connectionString="Data Source=|DataDirectory|Northwind.db;Version=3;FailIfMissing=True;"/>

  <!-- NHibernate Configuration -->
  <object id="NHibernateSessionFactory" type="Spring.Northwind.Dao.NHibernate.CustomLocalSessionFactoryObject, Spring.Northwind.Dao.NHibernate">
    <property name="DbProvider" ref="DbProvider"/>
    <property name="MappingAssemblies">
      <list>
        <value>Spring.Northwind.Dao.NHibernate</value>
      </list>
    </property>
    <property name="HibernateProperties">
      <dictionary>
        <entry key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/>
        <entry key="dialect" value="NHibernate.Dialect.SQLiteDialect"/>
        <entry key="connection.driver_class" value="NHibernate.Driver.SQLite20Driver"/>
        <entry key="use_proxy_validator" value="false" />
      </dictionary>
    </property>

    <!-- provides integation with Spring's declarative transaction management features -->
    <property name="ExposeTransactionAwareSessionFactory" value="true" />

  </object>

  <!-- Transaction Management Strategy - local database transactions -->
  <object id="transactionManager"
        type="Spring.Data.NHibernate.HibernateTransactionManager, Spring.Data.NHibernate32">

    <property name="DbProvider" ref="DbProvider"/>
    <property name="SessionFactory" ref="NHibernateSessionFactory"/>

  </object>

  <!-- Exception translation object post processor -->
  <object type="Spring.Dao.Attributes.PersistenceExceptionTranslationPostProcessor, Spring.Data"/>

  <!-- Data Access Objects -->
  <object id="CustomerDao" type="Spring.Northwind.Dao.NHibernate.HibernateCustomerDao, Spring.Northwind.Dao.NHibernate">
    <property name="SessionFactory" ref="NHibernateSessionFactory"/>
  </object>

  <object id="ProductDao" type="Spring.Northwind.Dao.NHibernate.HibernateProductDao, Spring.Northwind.Dao.NHibernate">
    <property name="SessionFactory" ref="NHibernateSessionFactory"/>
  </object>

  <object id="OrderDao" type="Spring.Northwind.Dao.NHibernate.HibernateOrderDao, Spring.Northwind.Dao.NHibernate">
    <property name="SessionFactory" ref="NHibernateSessionFactory"/>
  </object>

  <object id="CategoryDao" type="Spring.Northwind.Dao.NHibernate.HibernateCategoryDao, Spring.Northwind.Dao.NHibernate">
    <property name="SessionFactory" ref="NHibernateSessionFactory"/>
  </object>

  <object id="CustomerClassificationCalculator" type="Spring.Northwind.Domain.DefaultCustomerClassificationCalculator, Spring.Northwind.Dao">
    
  </object>

  <object id="CustomerEntityProtoType" type="Spring.Northwind.Domain.Customer, Spring.Northwind.Dao" singleton="false">
    <constructor-arg ref="CustomerClassificationCalculator" />
  </object>


</objects>
